package com.zjj.learn.designmodel.work.iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * 具体迭代器角色
 **/
public class StudentIteratorImpl implements StudentIterator{

    private List<Student> list;
    private int index = 0;

    /**
     * 构造器
     **/
    public StudentIteratorImpl(List<Student> list) {
        this.list = list;
    }

    @Override
    public boolean hasNeNext() {
        return this.index < this.list.size();
    }

    /**
     * 返回下一个角色
     **/
    @Override
    public Student next() {
        Student student = list.get(index);
        index++;
        return student;
    }
}
